import Vue from 'vue'
import Router from 'vue-router'
import Home from './views/Home/Home.vue'
import Search from './views/Search/Search.vue'
import Sort from './views/Sort/Sort.vue'
import My from './views/My/My.vue'

Vue.use(Router);
const router = new Router({
  mode: 'hash',
  base: process.env.BASE_URL,
  routes: [{
      path: '/',
      component: Home,
      redirect: '/home'
    },
    {
      path: '/home',
      name: 'Home',
      component: Home,
      meta: {
        keepAlive: true
      }
    },
    {
      path: '/search',
      name: 'search',
      component: Search,
      meta: {
        keepAlive: true
      },
    },
    {
      path: '/sort',
      name: 'sort',
      component: Sort,
      meta: {
        keepAlive: true
      }
    },
    {
      path: '/user',
      name: 'user',
      component: My,
      meta: {
        keepAlive: true
      },
    },
    {
      path: '/tv',
      name: 'tv',
      meta: {
        keepAlive: true
      },
      component: () => import('./views/TV/TV.vue')
    },
    {
      path: '/player',
      name: 'Player',
      component: () => import('./views/Player/Player.vue')
    },
    {
      path: '/videoList',
      name: 'VideoList',
      component: () => import('./views/VideoList/index.vue'),
      meta: {
        keepAlive: true
      },
    },
    {
      path: '/vip',
      name: 'VIP',
      component: () => import('./views/VIP/index.vue'),
      meta: {
        keepAlive: true
      },
    },
    {
      path: '/orderList',
      name: 'OrderList',
      meta: {
        keepAlive: true
      },
      component: () => import('./views/OrderList/index.vue')
    },
    {
      path: '/collectVideo',
      name: 'CollectVideo',
      meta: {
        keepAlive: true
      },
      component: () => import('./views/CollectList/index.vue')
    },
    {
      path: '/buyVideo',
      name: 'BuyVideo',
      meta: {
        keepAlive: true
      },
      component: () => import('./views/BuyVideo/index.vue')
    },
    {
      path: '/about',
      name: 'about',
      // route level code-splitting
      // this generates a separate chunk (about.[hash].js) for this route
      // which is lazy-loaded when the route is visited.
      component: () => import( /* webpackChunkName: "about" */ './views/About/About.vue')
    }
  ]
});
router.routerQueue = []; //路由历史
router.beforeEach((to, from, next) => {
  router.routerQueue.push(to.fullPath);
  next();
  //to and from are Route Object,next() must be called to resolve the hook}
})
export default router